package cn.tedu.es.service;

import cn.tedu.es.entity.Student;
import cn.tedu.es.repository.StudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: LiuXingYu
 * @date: 2021/9/29 10:43
 */
@Service
public class StudentService {

    @Autowired
    private StudentRepository studentRepo;

    public void save(Student student) {
        studentRepo.save(student);
    }

    public void delete(Long id) {
        studentRepo.deleteById(id);
    }

    public void update(Student student) {
        save(student);
    }

    public Page<Student> findByName(String name, Pageable pageable) {
        return studentRepo.findByName(name,pageable);
    }

    public List<Student> findByNameOrBirthDate(String name, String birthDate) {
        return studentRepo.findByNameOrBirthDate(name, birthDate);
    }
}
